package com.ssm.modules.service.impl;

import com.ssm.modules.dao.IProblemDao;
import com.ssm.modules.entity.Problem;
import com.ssm.modules.service.IProblemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @email: dong980514280@gmail.com
 * @author: HGL
 * @date: 2018/12/26
 * @time: 11:12
 */
@Service("problemService")
public class ProblemServiceImpl implements IProblemService {
    @Autowired
    private IProblemDao problemDao;

    public List<Problem> findByStuId(int stuId, int page, int pageSize) {
        if(page > 0) {
            page = (page - 1) * pageSize;
        }
        return problemDao.findByStuId(stuId, page, pageSize);
    }

    public int findByStuIdCount(int stuId) {
        return problemDao.findByStuIdCount(stuId);
    }

    public List<Problem> findByTeaId(int teaId, int page, int pageSize) {
        if(page > 0) {
            page = (page - 1) * pageSize;
        }
        return problemDao.findByTeaId(teaId, page, pageSize);
    }

    public int findByTeaIdCount(int teaId) {
        return problemDao.findByTeaIdCount(teaId);
    }

    public List<Problem> selectAll() {
        return problemDao.selectAll();
    }

    public int addProblem(Problem problem) {
        return problemDao.addProblem(problem);
    }

    public int updateProblem(Problem problem) {
        return problemDao.updateProblem(problem);
    }

    public int deleteProblem(int id) {
        return problemDao.deleteProblem(id);
    }

    public int updateReplay(int id, String reply) {
        return problemDao.updateReplay(id, reply);
    }
}
